/*
 * Pawn class that creates a pawn piece for the game Sorry!
 * @author: Jeffrey hatch
 * @date: 11/17/11
 */
public class Pawn
{
        private int positionIndex;
        private boolean start;
        private boolean home;
        private boolean inSZ;
        private int traveled;
        //private int homeIndex;  //TODO: Not sure if we want the ability to
                                                                // maybe figure out how many more spaces we have left before home.
       
        public Pawn()                     //(int homeIndex) if wanting to add homeIndex
        {
                //this.homeIndex = homeIndex;
                positionIndex = -1;
                start = true;
                home = false;
                inSZ = false;
                traveled = 0;
        }
        
        public void travel(int movement)
        {
        	traveled = traveled + movement;
        	if (traveled < -1)
        		traveled = traveled + 60;
        	if (traveled > 58)
        		changeSZ(true);
        	else
        		changeSZ(false);
        	if (traveled == 64)
        		changeHome(true);
        }
        

        /*
         * Gets the position of the pawn.
         * Returns positionIndex: position of the pawn.
         */
        public int getPositionIndex()
        {
                return positionIndex;
        }
       
        /*
         * Changes the position index of the pawn.
         */
        public void move(int newPosition)
        {
                positionIndex = newPosition;
        }
       
        /*
         * Checks to see if the pawn is in the safety zone.
         * Return inSZ: True if pawn is in the safety Zone otherwise false.
         */
        public boolean getSZ()
        {
                return inSZ;
        }
       
        /*
         * Checks to see if the pawn is at Home.
         * Returns home: True if pawn is located in Home otherwise false.
         */
        public boolean getHome()
        {
                return home;
        }
       
        /*
         * Checks to see if the pawn is at Start.
         * Returns start: True if pawn is located in Start otherwise false.
         */
        public boolean getStart()
        {
                return start;
        }
       
        /*
         * Changes if the pawn is located in start or not.
         * Input start: True if pawn is going to be located in Start, false otherwise
         */
        public void changeStart(boolean start)
        {
                this.start = start;
                if (start)
                	traveled = 0;
        }
       
        /*
         * Changes if the pawn is located at Home or not.
         * Input home: True if pawn is going to be located at Home, false otherwise
         */
        public void changeHome(boolean home)
        {
                this.home = home;
        }
       
        /*
         * Changes if the pawn is located in safety zone or not.
         * Input safeZone: True if pawn is going to be located in safety zone, false
         *                                      if the pawn is no longer in safetyZone.
         */
        public void changeSZ(boolean safeZone)
        {
                inSZ = safeZone;
        }
       
        /*
         * Checks to see if the pawn can move based on if the pawn is either in Home or Start.
         * Input move: TODO: If we want to include the ability to check if pawn has anymore moves
         *                                      available based on how close to Home it is.
         */
        public boolean isMovable(int move)
        {
                boolean canMove = false;
               
                if(positionIndex != -1)   //TODO: If we want to add the ability to check if the move is available
                {                                                       //    based on how close to home they are, this would be where we would want to do it.
                        canMove = true;
                }
               
                return canMove;
        }
}

